package com.serli.sample.data.runner.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@SuppressWarnings("serial")
@Entity
@Table(name= "COUREUR")
@NamedQueries({
    @NamedQuery(name = Runner.QUERY_FIND_ALL_ORDER_BY_FIRSTNAME, query = "SELECT OBJECT(r) FROM Runner r ORDER BY r.firstName"),
    @NamedQuery(name = Runner.QUERY_FIND_BY_FIRSTNAME, query = "SELECT OBJECT(r) FROM Runner r WHERE r.firstName = :firstName"),
    @NamedQuery(name = Runner.QUERY_DELETE_BY_NAMES, query = "DELETE FROM Runner r WHERE r.firstName = :firstName AND r.lastName = :lastName")
})
public class Runner implements Serializable {
	
    public static final String QUERY_FIND_ALL_ORDER_BY_FIRSTNAME = "findAllOrderByFirstName";
    public static final String QUERY_FIND_BY_FIRSTNAME = "findByFirstName";
    public static final String QUERY_DELETE_BY_NAMES = "deleteByNames";
    public static final String PARAMETER_FIRSTNAME = "firstName";
    public static final String PARAMETER_LASTNAME = "lastName";
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID_COUREUR")
	long id;
	
	@Basic
	@Column(name = "PRENOM", length = 32, nullable = false)
	String firstName;
	
	@Basic
	@Column(name = "NOM", length = 32)
	String lastName;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "DATE_NAISSANCE")
	Date birthDate;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}
}
